///////////////高级搜索的对话框
var advanceSearchDlg = null;
////综合统计对话框
var mutilpeStateDlg = null;
///影响区统计对话框
var affortAreaDlg = null;
//初始化查询信息框的表格  jbqk01
var graphParam = new Array();

function initTblJbqk01(){
	$('#tbljbqk01').datagrid({
		url:"",
		striped : true,
		pageSize : 10,
		height :324,
		width:280,
		nowrap : false,
		showPageList:false,
		rownumbers : true,
		columns : [[{
					field : '1',
					title : '灾点名称',
					width : 240,
					align : 'center',
					formatter : function(value, rec, rowIndex) {// value id rec
						// 该对象
						//curRecObj = rec;
						var name = rec.jbqk0110;
						//createMarkAndPopup();
						//var baleInfoArr.push(new baleInfoObj(baleCoding,baleName,x,y,town,village,group,baseInfo,baleUrl));
						return  "<span style='align:center;cursor:pointer;text-decoration: underline;' " +
						"onclick='toLocation(\""+rowIndex+"\","+rec.jbqk0120+","+rec.jbqk0130+")'>"
						+ name
						+ "</span>"
					}
				}]],
		onLoadSuccess : function() {
			//clearTaxLabel("clear");//清空地图上的图标
		},
		pagination : true,
		rownumbers : true,
		singleSelect : true
	});
}
//点击搜索之后的效果
function bfuncSearchBtnClick(){
	var region = $("#lyCode").val();
	var zhdType = $("#zhdTypeslt").val();
	var name = $("#searchInput").val();
	name = name=="请输入灾害点名称或地址"?"":name;
	var param = {
		"zhdType":zhdType,
		"name":name,
		"region":region
	}
	$(".innerStyle span").html("0");
	var sUrl = "findJbqk01ListByCondition.shtml";
	$('#tbljbqk01').datagrid({
				pageNumber : 1,
				url : sUrl,
				queryParams : param,
				onLoadSuccess : function(response) {
					top.closeForBaseInvestigate();
					if(response.rows==0) {
						alert('没有查询结果'); 
						return;
					}
					var groupVal = response.groupList;
					var count = 0;
					/*if(groupVal.length==1){
						$("#zhdGroup"+groupVal[0][0]).html(groupVal[0][1]);  
							count +=parseInt(groupVal[0][1]);
					}else {*/
					for(var i=0;i<groupVal.length;i++){
						$("#zhdGroup"+groupVal[i][0]).html(groupVal[i][1]);  
						count +=parseInt(groupVal[i][1]);
					}
					/*}*/
					$("#zhdGroupSum").html(count); 
					$("#zhdGroupCount").html(response.total);
					$("#dialogForQueryRes").dialog("open");
					top.addMarkAndPopup(response.rows);
				}
			});
}
//////高级搜索页面  html
var advanceSearchHtml = '<div class="queryDlg" style="width:380px;height:444px;font-family:微软雅黑;">' +
                          '<div class="qry"  style="height:50px;width:380px;margin-bottom:10px;"> <select style="display: none" id="sheng_advanc" onchange="changeShengItem(this.value,\'shi_advanc\')"><option  selected="selected" value="" >请选择省</option></select>' +
                         '<div style="padding-top:5px;padding-left:5px">行政区：</div>'+ 
                          '<table width="380px" border="0" cellspacing="0" cellpadding="0" >' +
                          '<tr><td class="queryCondition">省市区划</td><td><select id="shi_advanc" 	onchange="changeShiItem(this.value,\'xian_advanc\');">'+
	'<option  selected="selected" value="-1">湖北省</option></select></td>'+
	'<td class="queryCondition">县级区划</td><td>'+
	'<td><select id="xian_advanc" ><option  selected="selected" value="-1">请选择</option></select></td>'+
	'</table>'+
                          '</div>'+
                           '<div class="qry" id="districtbaseinves" style="height:100px;width:380px;margin-bottom:10px;">' +
                             '<div class="1" id="damage" style="height:40px;width:367px;margin-bottom:2px;">' +
                           '<div style="padding-top:5px;padding-left:5px">灾点类别：</div>'+
                           '<div id="checkDistrict" style="margin-top:5px;padding-left:18px">' +
                                '<table width="365px" border="0" cellspacing="0" cellpadding="0">' +
                                    '<tr>' +
                                         '<td class="queryCondition" width="64" height="28"><input type="checkbox" name="zdlb" value = "1"/>十万调查点</td>' +
                                         '<td class="queryCondition" width="64"><input type="checkbox" name="zdlb" value = "2"/>五万调查点</td>' +
                                         '<td class="queryCondition" width="64"><input type="checkbox" name="zdlb" value = "3"/>应急调查点</td>' +
                                     '</tr>' +
                                   '<tr>' +
                                         '<td class="queryCondition" width="64"><input type="checkbox" name="zdlb" value = "4"/>群测群防点</td>' +
                                         '<td class="queryCondition" width="64"><input type="checkbox" name="zdlb" value = "5"/>重大灾害点</td>' +                  
                                         '<td class="queryCondition" width="64"><input type="checkbox" name="zdlb" value = "6"/>应急监测点</td>' +                  
                                  '</tr>' +
                            '</table>' +
                            '<div style="margin-left:5px;margin-top:10px;font-size:11px; color:#0b3f87;">提示：您可以勾选多个灾点类别进行查询。</div>' +
                           '</div>' +
                           '</div>' +
                          '</div>' +
                           '<div class="qry" id="damage" style="height:120px;width:380px;margin-bottom:10px;">' +
                           '<div style="padding-top:5px;padding-left:5px">灾害类型：</div>'+
                           '<div id="checkDistrict" style="margin-top:5px;padding-left:18px">' +
                                '<table width="365px" border="0" cellspacing="0" cellpadding="0">' +
                                    '<tr>' +
                                         '<td class="queryCondition" width="62" height="28"><input type="checkbox" name="lx" value = "00"/>不稳定斜坡</td>' +
                                         '<td class="queryCondition" width="62"><input type="checkbox" name="lx" value = "01"/>滑坡</td>' +
                                         '<td class="queryCondition" width="62"><input type="checkbox" name="lx" value = "02"/>崩塌</td>' +
                                         '<td class="queryCondition" width="62"><input type="checkbox" name="lx" value = "04"/>岩溶塌陷</td>' +
                                         '<td class="queryCondition" width="62"><input type="checkbox" name="lx" value = "03"/>泥石流</td>' +                  
                                  '</tr>' +
                                   '<tr>' +
                                         '<td class="queryCondition" width="62" height="28"><input type="checkbox" name="lx" value = "05"/>采空塌陷</td>' +
                                         '<td class="queryCondition" width="62"><input type="checkbox" name="lx" value = "06"/>地裂缝</td>' +
                                         '<td class="queryCondition" width="62"><input type="checkbox" name="lx" value = "07"/>地面沉降</td>' +
                                         '<td class="queryCondition" width="62"><input type="checkbox" name="lx" value = "08"/>塌岸</td>' +
                                         '<td class="queryCondition" width="62"><input type="checkbox" name="lx" value = "09"/>高切坡</td>' +                  
                                  '</tr>' +
                                   '<tr>' +
                                         '<td class="queryCondition" width="64" height="28"><input type="checkbox" name="lx" value = "10"/>危岩体</td>' +
                                         '<td colspan="4"> <div style="margin-left:5px;margin-top:10px;font-size:11px; color:#0b3f87;">提示：您可以勾选多个灾害类型进行查询。</div> </td>'+
                                  '</tr>' +
                            '</table>' +
                           
                           '</div>' +
                           '</div>' +
                           '<div  class="qry" id="graph" style="height:80px;width:380px;margin-bottom:10px;">' +
                           '<div style="padding-top:5px;padding-left:5px">范围限定：</div>' +
                           '<div  style="margin-left:50px;margin-top:10px;">' +
                               '<input id="graphRange" class="graphchange" type="radio" name="graph" value="box">拉框</input>' +
                               '<input id="graphCircle"  class="graphchange" type="radio" name="graph" value="circle" >画圆</input>' +
                           '</div>' +
                           '<div style="margin-left:20px;margin-top:10px;font-size:11px;color:#0b3f87;">提示：您可以点击图片之后，在地图上进行拉框限定范围。</div>' +
                           '</div>' +
                           '<div id="queryButton" title="点击查询" style="cursor:pointer;width:55px; margin-top:20px; height:26px;color:#0F6203;line-height:24px;text-align:center; float:right;">确&nbsp;&nbsp;定</div>' +
                        '</div>';

function initAdvanceSearch(){
	if(advanceSearchDlg)
		return;
	//拉框的范围  拷贝大连项目
var lakuangRang = [];


	advanceSearchDlg = $.dialog({
		title: '高级查询',
		content: advanceSearchHtml,
		dlgDivId: "advanceSearchId",
		resize: false,
		max: false,
		left:"0px",
		top:'150px',
		width:'340px',
		height:'444px',
		min:advanceSearchMinFunc,
		init:function(){
			//对按钮的监听
			var lyCodeStr = lyCode.toString();
			var shengCode = lyCodeStr.substring(0,2);
			var shiCode = lyCodeStr.substring(2,4)=="00"?"00":lyCodeStr.substring(0,4)+"00";
			var xianCode = lyCodeStr.substring(4,6)=="00"?"00":lyCodeStr;
			
			setOption('china','sheng_advanc');
			$("#sheng_advanc").attr("disabled","disabled");
            setSltDefaultVal("sheng_advanc",lyCodeStr);
            changeShengItem("420000",'shi_advanc');
            if(shiCode!="00"){
            	setSltDefaultVal("shi_advanc",shiCode);
				changeShiItem($("#shi_advanc").val(),'xian_advanc');
				$("#shi_advanc").attr("disabled","disabled");
            }
            if(xianCode!="00"){
            	setSltDefaultVal("shi_advanc",shiCode);
				changeShiItem($("#shi_advanc").val(),'xian_advanc');
				$("#shi_advanc").attr("disabled","disabled");
				setSltDefaultVal("xian_advanc",xianCode);
				$("#xian_advanc").attr("disabled","disabled");
            }
			$("#queryButton").click(advanceSearchClk);
		},
		close:advanceSearchDlgCloseFunc
	});
	initForBaseInvestigate();//注册地图查询事件
}
///高级搜索的按钮事件
function advanceSearchClk(){
	var region ="420000";
	if($("#xian_advanc").val()!="-1"){
		region = $("#xian_advanc").val();
	}else if($("#shi_advanc").val()!="-1"){
		region = $("#shi_advanc").val();
	}
	var lx = [];
	var lxLength = $("input[name='lx']:checked").length;
    for (var i = 0; i < lxLength; i++) {
        lx.push($("input[name='lx']:checked")[i].value);
    }
   // debugger;
   // var l = graphParam.length;
    var groupArr = [];
    var gplength = $("input[name='zdlb']:checked").length;
    for (var i = 0; i < gplength; i++) {
        groupArr.push($("input[name='zdlb']:checked")[i].value);
    }
	var param = {
		"region":region,///行政区
		"zhdType":lx.toString(),//灾害类型
		"zhdGroupType":groupArr.toString(), //灾害分组
		"graphParam":graphParam.length==0?"":graphParam.toString()//图形范围
	}
	$(".innerStyle span").html("0");
	var sUrl = "findJbqk01ListByAdvanceCondition.shtml";
	$('#tbljbqk01').datagrid({
				pageNumber : 1,
				url : sUrl,
				queryParams : param,
				onLoadSuccess : function(response) {
					top.closeForBaseInvestigate();
					queryBaseInvestigate();
					if(response.rows==0) {
						alert('没有查询结果'); 
						return;
					}
					var groupVal = response.groupList;
					var ct = 0;
					if(groupVal.length==1){
						$("#zhdGroup"+groupVal[0][0]).html(groupVal[0][1]);  
							ct +=parseInt(groupVal[0][1]);
					}else {
						for(var i=0;i<groupVal.length;i++){
							$("#zhdGroup"+groupVal[i][0]).html(groupVal[i][1]);  
							ct +=parseInt(groupVal[i][1]);
						}
					}
					$("#zhdGroupSum").html(ct); 
					$("#zhdGroupCount").html(response.total);
					$("#dialogForQueryRes").dialog("open");
					top.addMarkAndPopup(response.rows);
				}
			});
}
function advanceSearchDlgCloseFunc(){
	advanceSearchDlg = null;
	closeForBaseInvestigate();
	queryBaseInvestigate();
}
function advanceSearchMinFunc(){
	minDlgByAnimate(advanceSearchDlg);
}
/*初始化对话框内容*/
var initForBaseInvestigate = function () {
	
    var polygonLayer = new OpenLayers.Layer.Vector('RegularPolygonLayer');
    queryBaseInvestigate.controlgraph1 = null;
    queryBaseInvestigate.controlgraph2 = null;
    map.addLayer(polygonLayer);
    //$("#next").click(queryBaseInvestigate);
    queryBaseInvestigate.graphLayer = polygonLayer;
  	graphMap.polygonLayer = polygonLayer;
    $(".graphchange").click(graphMap);
}
/*判断使用何种画图方式的方法函数*/
function graphMap() {
    var graphway = $("input[name='graph']:checked").val();
    if (graphway == "box") {
        control = new OpenLayers.Control.DrawFeature(graphMap.polygonLayer, OpenLayers.Handler.RegularPolygon, { handlerOptions: { irregular: true} });
        queryBaseInvestigate.controlgraph1 = control;
 	}
    if (graphway == "circle") {
        control = new OpenLayers.Control.DrawFeature(graphMap.polygonLayer, OpenLayers.Handler.RegularPolygon, { handlerOptions: { sides: 500} });
        queryBaseInvestigate.controlgraph2 = control;
    }
    map.addControl(control);
    control.featureAdded = deletFormer;
    control.activate();
}

/*删除上一个绘图区域并获取相关经纬度*/
var flag = false;
function deletFormer(evt) {
    graphParam = [];
    var graphway1 = $("input[name='graph']:checked").val();
    var l = evt.layer.features.length;
    if(l==2)
   		evt.layer.removeFeatures(evt.layer.features[0]);
    var x1 = evt.layer.features[0].geometry.bounds.top;
    var x2 = evt.layer.features[0].geometry.bounds.bottom;
    var y1 = evt.layer.features[0].geometry.bounds.left;
    var y2 = evt.layer.features[0].geometry.bounds.right;
    var min = Mercator2lonLat(y1,x2);
	var max = Mercator2lonLat(y2,x1);
    if (graphway1 == "box") {
        //alert("区域的经度范围：" + y1 + "--" + y2 + "\n纬度范围：" + x2 + "--" + x1);
    	
        graphParam.push(min.x);
        graphParam.push(min.y);
        graphParam.push(max.x);
        graphParam.push(max.y);
    } else {
       //alert("中心点坐标为：" + evt.layer.features[0].geometry.bounds.getCenterLonLat() + "\n半径为" + (x1 - x2) / 2);
    	var center =Mercator2lonLat(evt.layer.features[0].geometry.bounds.getCenterLonLat().lon,evt.layer.features[0].geometry.bounds.getCenterLonLat().lat);
    	
    	graphParam.push(center.x);
       graphParam.push(center.y);
       graphParam.push((max.x - min.x) / 2);
    }
  
}
///无效函数  
function queryBaseInvestigate() {
	 queryBaseInvestigate.graphLayer.removeFeatures(queryBaseInvestigate.graphLayer.features[0]);
    if (queryBaseInvestigate.controlgraph1) {
        queryBaseInvestigate.controlgraph1.deactivate();
    }
    if (queryBaseInvestigate.controlgraph2) {
        queryBaseInvestigate.controlgraph2.deactivate();
    }
}
//////////年份select 
var yearSltOptStr =  '<option   value="2000">2000年</option>' +
                                         '<option   value="2001">2001年</option>' +
                                         '<option   value="2002">2002年</option>' +
                                         '<option   value="2003">2003年</option>' +
                                         '<option   value="2004">2004年</option>' +
                                         '<option   value="2005">2005年</option>' +
                                         '<option   value="2006">2006年</option>' +
                                         '<option   value="2007">2007年</option>' +
                                         '<option   value="2008">2008年</option>' +
                                         '<option   value="2009">2009年</option>' +
                                         '<option   value="2010">2010年</option>' +
                                         '<option   value="2011">2011年</option>' +
                                         '<option   value="2012">2012年</option>' +
                                         '<option  selected="selected" value="2013">2013年</option>' +
                                         '<option   value="2014">2014年</option>' +
                                         '<option   value="2015">2015年</option>' ;
////////////////////////////////综合统计
var mutilpeStateHtml  = '<div class="queryDlg" style="width:380px;height:400px;font-family:微软雅黑;">' +
                          '<div class="qry"  style="height:50px;width:380px;margin-bottom:10px;"> <select style="display: none" id="sheng_mutilpeState" onchange="changeShengItem(this.value,\'shi_mutilpeState\')"><option  selected="selected" value="" >请选择省</option></select>' +
                         '<div style="padding-top:5px;padding-left:5px">行政区：</div>'+ 
                          '<table width="380px" border="0" cellspacing="0" cellpadding="0" >' +
                          '<tr><td class="queryCondition">省市区划</td><td><select id="shi_mutilpeState" 	onchange="changeShiItem(this.value,\'xian_mutilpeState\');">'+
	'<option  selected="selected" value="-1">湖北省</option></select></td>'+
	'<td class="queryCondition">县级区划</td><td>'+
	'<td><select id="xian_mutilpeState" ><option  selected="selected" value="-1">请选择</option></select></td>'+
	'</table>'+
                          '</div>'+
                           '<div class="qry" id="districtbaseinves" style="height:120px;width:380px;margin-bottom:10px;">' +
                             '<div class="1" id="damage" style="height:40px;width:367px;margin-bottom:2px;">' +
                           '<div style="padding-top:5px;padding-left:5px">统计类别：</div>'+
                           '<div id="checkDistrict" style="margin-top:5px;padding-left:18px">' +
                                '<table width="365px" border="0" cellspacing="0" cellpadding="0">' +
                                    '<tr>' +
                                         '<td class="queryCondition" width="64" height="28"><input type="radio" name="statType" checked value = "1" onclick="changeSecondDiv(this.value)"/>多年度应急调查次数统计</td>' +
                                     '</tr>' +
                                   '<tr>' +
                                         '<td class="queryCondition" width="64"><input type="radio" name="statType" value = "2" onclick="changeSecondDiv(this.value)"/>单年度应急调查点统计</td>' +
                                  '</tr>' +
                                   '<tr>' +
                                         '<td class="queryCondition" width="64"><input type="radio" name="statType" value = "3" onclick="changeSecondDiv(this.value)"/>业务数据综合统计</td>' +
                                  '</tr>' +
                                   '<tr>' +
                                         '<td class="queryCondition" width="64"><input type="radio" name="statType" value = "4" onclick="changeSecondDiv(this.value)"/>业务数据威胁对象统计</td>' +
                                  '</tr>' +
                            '</table>' +
                           '</div>' +
                          '</div>' +
                           '</div>' +
                            '<div class="qry" id="districtbaseinves" style="height:60px;width:380px;margin-bottom:10px;">' +
                             '<div class="1" id="damage" style="height:40px;width:367px;margin-bottom:2px;">' +
                           '<div style="padding-top:5px;padding-left:5px">统计条件：</div>'+
                           '<div id="mutilpeYears" style="margin-top:5px;padding-left:18px">' +
                                '<table width="365px" border="0" cellspacing="0" cellpadding="0">' +
                                    '<tr>' +
                                         '<td class="queryCondition" width="64" height="28">起始年度<select id="sYear">' +
                                       		yearSltOptStr+'</select></td>' +
                                     	'<td class="queryCondition" width="64">终止年度<select id="eYear" >' +
                                       		yearSltOptStr+'</select></td>' +
                                    '</tr>' +
                            	'</table>' +
                          	 '</div>' +
                          	  '<div id="singleYear" style="margin-top:5px;padding-left:18px;display:none">' +
                                '<table width="365px" border="0" cellspacing="0" cellpadding="0">' +
                                    '<tr>' +
                                         '<td class="queryCondition" width="64" height="28">选择年度<select id="sltyear">' +
                                       		yearSltOptStr+'</select></td>' +
                                    '</tr>' +
                            	'</table>' +
                          	 '</div>' +
                          	 
                          '</div>' +
                           '</div>' +
                           '<div id="queryButton" title="点击统计" style="cursor:pointer;width:55px; margin-top:20px; height:26px;color:#0F6203;line-height:24px;text-align:center; float:right;">统&nbsp;&nbsp;计</div>' +
                        '</div>';
function initMutilpeState(){
	if(mutilpeStateDlg)
		return;
	mutilpeStateDlg = $.dialog({
		title: '综合统计',
		content: mutilpeStateHtml,
		dlgDivId: "MutilpeStateHtml",
		resize: false,
		max: false,
		left:"0px",
		top:'150px',
		width:'340px',
		height:'400px',
		min:mutilpeStateDlgMinFunc,
		init:function(){
			//对按钮的监听
			var lyCodeStr = lyCode.toString();
			var shengCode = lyCodeStr.substring(0,2);
			var shiCode = lyCodeStr.substring(2,4)=="00"?"00":lyCodeStr.substring(0,4)+"00";
			var xianCode = lyCodeStr.substring(4,6)=="00"?"00":lyCodeStr;
			
			setOption('china','sheng_mutilpeState');
			$("#sheng_mutilpeState").attr("disabled","disabled");
            setSltDefaultVal("sheng_mutilpeState",lyCodeStr);
            changeShengItem("420000",'shi_mutilpeState');
            if(shiCode!="00"){
            	setSltDefaultVal("shi_mutilpeState",shiCode);
				changeShiItem($("#shi_mutilpeState").val(),'xian_mutilpeState');
				$("#shi_mutilpeState").attr("disabled","disabled");
            }
            if(xianCode!="00"){
            	setSltDefaultVal("shi_mutilpeState",shiCode);
				changeShiItem($("#shi_mutilpeState").val(),'xian_mutilpeState');
				$("#shi_mutilpeState").attr("disabled","disabled");
				setSltDefaultVal("xian_mutilpeState",xianCode);
				$("#xian_mutilpeState").attr("disabled","disabled");
            }
			$("#queryButton").click(mutilpeStateClk);
		},
		close:mutilpeStateDlgCloseFunc
	});
}
function mutilpeStateDlgCloseFunc(){
	mutilpeStateDlg = null;
}
function mutilpeStateDlgMinFunc(){
	minDlgByAnimate(mutilpeStateDlg);
}
/////综合统计点击事件
function mutilpeStateClk(){
	var type = $("input[name='statType']:checked")[0].value;
	var region ="420000";
	if($("#xian_mutilpeState").val()!="-1"){
		region = $("#xian_mutilpeState").val();
	}else if($("#shi_mutilpeState").val()!="-1"){
		region = $("#shi_mutilpeState").val();
	} 
	var sUrl = "";

	var data = {};
	switch(type){
	case "1":
		sUrl = "stateYjdcCountByYears.shtml";
		data = {
			"region":region,///行政区
			"sYear":$("#sYear").val(),
			"eYear":$("#eYear").val()
		};
		break;
	case "2":
		sUrl = "stateYjdcCountByOneYear.shtml";
		data = {
			"region":region,///行政区
			"year":$("#sltyear").val()
		};
		break;
	case "3":
		sUrl = "mutilpeStateBaseInfoGroupByOper.shtml";
		data = {
			"region":region///行政区
		};
		break;
	case "4":
		sUrl = "mutilpeStateBaseInfoGroupByTheat.shtml";
		data = {
			"region":region///行政区
		};
		break;
	}
	$.post(sUrl,data,cbMutilpeStateClk);
}
function cbMutilpeStateClk(res){

	var chart = new FusionCharts("lib/fusionChart/"+res.stateType+"", "ChartId", "400", "300", "0", "0");
	chart.setDataXML(res.jsonResult);		   
	chart.render("MultipleState_chartDiv");
	$('#dialogForMultipleState').dialog("open");
}
function changeSecondDiv(val){
	if(val==1){
		$("#mutilpeYears").css("display","");
		$("#singleYear").css("display","none");
	}else if(val==2){
		$("#mutilpeYears").css("display","none");
		$("#singleYear").css("display","");
	}else{
		$("#mutilpeYears").css("display","none");
		$("#singleYear").css("display","none");
	}
}

//////////////////////////////影响区统计
var affortAreaHtml  = '<div class="queryDlg" style="width:380px;height:140px;font-family:微软雅黑;">' +
                          '<div class="qry" id="districtbaseinves" style="height:60px;width:380px;margin-bottom:10px;">' +
                             '<div class="1" id="damage" style="height:40px;width:367px;margin-bottom:2px;">' +
                           '<div style="padding-top:5px;padding-left:5px">统计参数：</div>'+
                           '<div id="checkDistrict" style="margin-top:5px;padding-left:18px">' +
                                '<table width="365px" border="0" cellspacing="0" cellpadding="0">' +
                                    '<tr>' +
                                         '<td class="queryCondition" width="64" height="28">威胁资产</td>' +
                                         '<td class="queryCondition" width="64">威胁人口</td>' +
                                         '<td class="queryCondition" width="64">威胁户数</td>' +
                                     '</tr>' +
                                  /* '<tr>' +
                                         '<td class="queryCondition" width="64"><input type="checkbox" name="zdlb" value = "4"/>群测群防点</td>' +
                                         '<td class="queryCondition" width="64"><input type="checkbox" name="zdlb" value = "5"/>重大灾害点</td>' +                  
                                  '</tr>' +*/
                            '</table>' +
                            //'<div style="margin-left:5px;margin-top:10px;font-size:11px; color:#0b3f87;">提示：您可以勾选多个灾点类别进行查询。</div>' +
                           '</div>' +
                           '</div>' +
                          '</div>' +
                          '<div  class="qry" id="graph" style="height:80px;width:380px;margin-bottom:10px;">' +
                           '<div style="padding-top:5px;padding-left:5px">影响区范围限定：</div>' +
                           '<div  style="margin-left:50px;margin-top:10px;">' +
                               '<input id="graphRange" class="graphchange" type="radio" name="graph" value="box">拉框</input>' +
                               '<input id="graphCircle"  class="graphchange" type="radio" name="graph" value="circle" >画圆</input>' +
                           '</div>' +
                           '<div style="margin-left:20px;margin-top:10px;font-size:11px;color:#0b3f87;">提示：您可以点击图片之后，在地图上进行拉框限定范围。</div>' +
                           '</div>' +
                           '<div id="affectAreaStatButton" title="点击统计" style="cursor:pointer;width:55px; margin-top:20px; height:26px;color:#0F6203;line-height:24px;text-align:center; float:right;">确&nbsp;&nbsp;定</div>' +
                        '</div>';
function initEffortArea(){
	if(affortAreaDlg)
		return;
	affortAreaDlg = $.dialog({
		title: '影响区信息',
		content: affortAreaHtml,
		dlgDivId: "affortAreaHtml",
		resize: false,
		max: false,
		left:"0px",
		top:'150px',
		width:'340px',
		height:'140px',
		min:affortAreaDlgDlgMinFunc,
		init:function(){
			$("#affectAreaStatButton").click(affectAreaStatClk);
		},
		close:affortAreaDlgCloseFunc
	});
	initForBaseInvestigate();//注册地图查询事件
}
function affortAreaDlgCloseFunc(){
	affortAreaDlg = null;
	closeForBaseInvestigate();
	queryBaseInvestigate();
}
function affortAreaDlgDlgMinFunc(){
	minDlgByAnimate(affortAreaDlg);
}
///影响区统计
function affectAreaStatClk(){
	var param = {
		"graphParam":graphParam.length==0?"":graphParam.toString()//图形范围	
	}
	var sUrl = "affectAreaStatTheat.shtml";
	$.post(sUrl,param,cbAffectAreaStatClk);
}
function cbAffectAreaStatClk(res){
	var rows = res.rows;
	var yjzy = res.yjzyRows;
	var jcjg = res.jcyjRows;
	var showDetailsHtml = '';
	var typeDetailsHtml = '';
	var pntArr = new Array();
	var zhType = ["不稳定斜坡", "滑坡", "崩塌", "泥石流", "岩溶塌陷", "地裂缝", "地面沉降"];
	var labelName = ["物理点总数","威胁人口","威胁户数","威胁财产"];
	var rsCount = 0;//总人口	
	var hsCount = 0;//总户数	
	var zcCount = 0;//总资产数	
	for(var i=0;i<rows.length;i++){
		var tempHtml = '';
		var tmpArr = rows[i];//某一类型的结果数组		
		var typersCount = 0;
		var typehsCount = 0;
		var typezcCount = 0;
		for(var j=0;j<tmpArr.length;j++){
			//该类型下的所有结果数据			
			var obj = tmpArr[j];//取到该类型下的某一个数据			
			var rs = obj[11]==null?0:obj[11];
			var hs = obj[12]==null?0:obj[12];
			var zc = obj[13]==null?0:obj[13];
			typersCount +=rs;//分灾害类型总人口			
			typehsCount +=hs;//分灾害类型总户数			
			typezcCount +=zc;//分灾害类型总资产			
			pntArr.push(new AffectAreaStatObject(obj[0],obj[1],obj[2],obj[3],obj[4],obj[5],obj[6],obj[7],obj[8],obj[9]));
		}
		rsCount +=typersCount;
		hsCount +=typehsCount;
		zcCount +=typezcCount;
	}
	zcCount = zcCount.toString().substring(0,zcCount.toString().indexOf(".")+3);
	showDetailsHtml = '<div style="padding-top:5px;padding-bottom:5px;font-size: 20px;text-align: center;"><b>威胁对象信息</b></div>'+
			'<div style="padding-bottom:5px;font-size: 16px;color:red;text-align: center;">'+
		'<span style="color: blue;">灾害点总数：</span>'+pntArr.length+'&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue;">威胁总人数：</span>'+rsCount+'&nbsp;&nbsp;&nbsp;&nbsp;'+
		'<span style="color: blue;">威胁户数（户）：</span>'+hsCount +
		'<span style="color: blue;">威胁财产总数（万元）：</span>'+zcCount+
		'</div>';
	///////拼接监测机构
	var jcjgDetailsHtml = '<div style="padding-top:5px;padding-bottom:5px;font-size: 20px;text-align: center;"><b>监测预警机构</b></div>';
	jcjgDetailsHtml +='<table id="borderjg" class="statYuAnBorder" >' +
			'<tr><th style="width: 40%">机构名称</th>' +
			'<th style="width: 20%">机构类别</th>' +
			'<th style="width: 20%">负责人名称</th>' +
			'<th style="width: 20%">负责人电话</th>' +
			'</tr>';
	
	for(var i=0;i<jcjg.length;i++){
		var obj = jcjg[i];
		var jgmc = obj[0];
		var jglb = obj[1]=="A"?"专业监测":"群测群防";
		var fzrmc= obj[3]==null?"":obj[3];
		var tel = obj[4]==null?"":obj[4];
		jcjgDetailsHtml +='<tr><td>'
			+jgmc+'</td><td>'+jglb +'</td><td>'+fzrmc+'</td><td>'+tel+'</td></tr>';
	}
	jcjgDetailsHtml +='</table>';
	/////////拼接应急资源
	var yjzyDetailsHtml = '<div style="padding-top:5px;padding-bottom:5px;font-size: 20px;text-align: center;"><b>应急资源</b></div>'+
		'<table id="borderzy" class="statYuAnBorder" >' +
			'<tr><th style="width: 20%">资源所属单位</th>' +
			'<th style="width: 20%">资源管理负责人</th>' +
			'<th style="width: 20%">电话</th>' +
			'<th style="width: 20%">资源使用状态</th>' +
			'<th style="width: 20%">资源类型</th>' +
			'</tr>';
	
	for(var i=0;i<yjzy.length;i++){
		var obj = yjzy[i];
		var zydw = obj[0];
		var zyfzr = obj[1]==null?"":obj[1];
		var tel= obj[2]==null?"":obj[2];
		var zyzt = obj[3]==0?"未使用":"使用中";
		var lx = "";
		var zylx = obj[4];
		if(zylx==1){
			lx="人员";
		}else if(zylx==2){
			lx="车辆";
		}else if(zylx==3){
			lx="设备";
		}else if(zylx==4){
			lx="卫星资源";
		}
		yjzyDetailsHtml +='<tr><td>'+zydw+'</td><td>'+zyfzr +'</td><td>'+tel+'</td><td>'+zyzt+'</td><td>'+lx+'</td></tr>';
	}
	yjzyDetailsHtml +='</table>';
	showDetailsHtml += jcjgDetailsHtml+yjzyDetailsHtml;
	top.addMarkAndPopup(pntArr);///地图上添加点	
	$("#affectAreaStatRes").html(showDetailsHtml);
	setStatResTblStyle();
	$('#dialogForAffectAreaStat').dialog("open");
}
function cbAffectAreaStatClk_bk(res){
	var rows = res.rows;
	var showDetailsHtml = '';
	var typeDetailsHtml = '';
	var pntArr = new Array();
	var zhType = ["不稳定斜坡", "滑坡", "崩塌", "泥石流", "岩溶塌陷", "地裂缝", "地面沉降"];
	var labelName = ["物理点总数","威胁人口","威胁户数","威胁财产"];
	var rsCount = 0;//总人口	
	var hsCount = 0;//总户数	
	var zcCount = 0;//总资产数	
	for(var i=0;i<rows.length;i++){
		var tempHtml = '';
		var tmpArr = rows[i];//某一类型的结果数组		
		var typersCount = 0;
		var typehsCount = 0;
		var typezcCount = 0;
		for(var j=0;j<tmpArr.length;j++){
			//该类型下的所有结果数据			
			var obj = tmpArr[j];//取到该类型下的某一个数据			
			var rs = obj[11]==null?0:obj[11];
			var hs = obj[12]==null?0:obj[12];
			var zc = obj[13]==null?0:obj[13];
			typersCount +=rs;//分灾害类型总人口			
			typehsCount +=hs;//分灾害类型总户数			
			typezcCount +=zc;//分灾害类型总资产			
			var objHtml = '<tr><td>'+
			'<a href="javascript:toLocation(\''+pntArr.length+'\',\''+obj[2]+'\',\''+obj[3]+'\')">'+obj[1]+'</a>'+
			'</td><td>'+rs+' </td><td>'+hs+'</td><td>'+zc+'</td></tr>';
			tempHtml += objHtml;
			pntArr.push(new AffectAreaStatObject(obj[0],obj[1],obj[2],obj[3],obj[4],obj[5],obj[6],obj[7],obj[8],obj[9]));
		}
		rsCount +=typersCount;
		hsCount +=typehsCount;
		zcCount +=typezcCount;
		typeDetailsHtml += '<div  style=" background-color: buttonface;cursor: pointer;color: blue;width: 98%" onclick="isShowDisplay('+i+')">'+
			'<table style="border: 0;width: 98%;color: black;"><tr><td style="border: 0;width: 15%;">'+
			zhType[i]+'</td><td style="border: 0;width: 20%">物理点数：'+tmpArr.length+''+
			'</td><td style="border: 0;width: 20%">威胁总人数(人)：'+typersCount+''+
			'</td><td style="border: 0;width: 20%">威胁总户数(户)：'+typehsCount+''+
			'</td><td style="border: 0;width: 25%">威胁财产总数(万元)：'+typezcCount+''+
			'</td></tr></table></div>' +
			'<div style="height: 1px;"></div>' +
			'<div id="res'+i+'" class="statDetails" style="padding-left: 30px;display: none;width:98%">' +
			'<div style="padding-left: 5px;padding-bottom: 5px;padding-top: 5px;font-size: 10px;">' +
			'<table id="border'+i+'" class="statYuAnBorder" >' +
			'<tr><th style="width: 40%">名称</th>' +
			'<th style="width: 20%">威胁人数(人)</th>' +
			'<th style="width: 20%">威胁户数(户)</th>' +
			'<th style="width: 20%">威胁财产数(万元)</th>' +
			'</tr>'+
			tempHtml+
			'</table></div></div>';
	}
	showDetailsHtml = '<div style="padding-top:5px;padding-bottom:5px;font-size: 20px;text-align: center;"><b>灾害点分类显示</b></div>'+
			'<div style="padding-bottom:5px;font-size: 16px;color:red;text-align: center;">'+
		'<span style="color: blue;">灾害点总数：</span>'+pntArr.length+'&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue;">威胁总人数：</span>'+rsCount+'&nbsp;&nbsp;&nbsp;&nbsp;'+
		'<span style="color: blue;">威胁户总数（万元）：</span>'+hsCount +
		'<span style="color: blue;">威胁财产总数（万元）：</span>'+zcCount+'</div>' +
		'<div style="padding-bottom:20px;font-size: 14px;text-align: center;">'+
		typeDetailsHtml+
		'</div>';
	top.addMarkAndPopup(pntArr);///地图上添加点	
	///加载统计图	
 	var chartXML = "<chart palette='2' caption='影响区统计' xAxisName='统计对象' yAxisName='数量' showValues='0' decimals='0' formatNumberScale='0' useRoundEdges='1'>";
	chartXML += "<set label='"+labelName[0]+"' value='"+pntArr.length+"' />";	
 	chartXML += "<set label='"+labelName[1]+"' value='"+rsCount+"' />";
		chartXML += "<set label='"+labelName[2]+"' value='"+hsCount+"' />";
		chartXML += "<set label='"+labelName[3]+"' value='"+zcCount+"' />";
	chartXML = chartXML +"</chart>";
	var chart = new FusionCharts("lib/fusionChart/Column2D.swf", "ChartId", "400", "300", "0", "0");
	chart.setDataXML(chartXML);		   
	chart.render("AffectAreaStat_chartDiv");
	$("#affectAreaStatRes").html(showDetailsHtml);
	setStatResTblStyle();
	$('#dialogForAffectAreaStat').dialog("open");
}
function AffectAreaStatObject(jbqk0100,jbqk0110,jbqk0120,jbqk0130,jbqk0140,jbqk0150,jbqk0160,jbqk0170,jbqk0180,jbqk0190,jbqk0102){
	this.jbqk0100 = jbqk0100;
	this.jbqk0110 = jbqk0110;
	this.jbqk0120 = jbqk0120;
	this.jbqk0130 = jbqk0130;
	this.jbqk0140 = jbqk0140;
	this.jbqk0150 = jbqk0150;
	this.jbqk0160 = jbqk0160;
	this.jbqk0170 = jbqk0170;
	this.jbqk0180 = jbqk0180;
	this.jbqk0190 = jbqk0190;
	this.jbqk0102 = jbqk0102;
}
function isShowDisplay(num){
	$(".statDetails").css("display","none");
	$("#res"+num).css("display","");
	
}
function setStatResTblStyle(){
	$('.statYuAnBorder tr:odd').addClass('statOdd');//奇数行颜色
	$('.statYuAnBorder tr:even').addClass('statEven');//偶数行颜色
	$('th').parent().removeClass().addClass('table_heading');//设置标题行
}
